/***************************************************************************
 创建者：华磊
 开始时间：         : 2020.12.17
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   跳过指令属性编辑视窗
*                                                                         *
 ***************************************************************************/
#include "skipconditionview.h"
#include "ui_skipconditionview.h"
#include "../../programView/programview.h"


SkipConditionView::SkipConditionView(QWidget *parent):
    QWidget(parent),
    ui(new Ui::SkipConditionView)
{
    ui->setupUi(this);
}

void SkipConditionView::updateView()
{
    if(1 == conditionHeadFlag)
    {
        ui->conditionHead_radioButton->setChecked(true);
    }
    if(1 == conditionTailFlag)
    {
        ui->conditionTail_radioButton->setChecked(true);
    }

    ui->conditionHead_lineEdit->setText(condition);

    ui->lblIndex_lineEdit->setText(lblIndex);
    ui->note_lineEdit->setText(note);
}

void SkipConditionView::getInput()
{
    condition = ui->conditionHead_lineEdit->text();
    lblIndex = ui->lblIndex_lineEdit->text();
    note = ui->note_lineEdit->text();
}

void SkipConditionView::on_conditionHead_radioButton_clicked()
{
    emit selectConditionHead();
}

void SkipConditionView::on_conditionTail_radioButton_clicked()
{
    emit selectConditionTail();
}

void SkipConditionView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->clear();
    emit clearNote();
}

void SkipConditionView::on_forward_Btn_clicked()
{
    this->close();
    programView->instructionListFlag = 0;
    programView->editInstructionViewShowOrHide();
}

void SkipConditionView::on_save_Btn_clicked()
{
    getInput();

    emit finishEditInstruction();
    emit saveInstruction(conditionSkipHead);
    emit saveInstruction(conditionSkipTail);
}

void SkipConditionView::changeLanguage(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/skipViewEnglishLan.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }
    ui->retranslateUi(this);
}
